<template>
  <div class="zhifu">
      <div class="city">
        <h4>收货地址</h4>
        <div v-for="(item,index) in citys" :key="index" @click="actindex=index">
          <span>{{item.city}}</span>
          <span><b v-show="actindex===index" class="sp">√</b></span>
        </div>
      </div>
      <div class="zifu">
        <h4>支付方式</h4>
        <div v-for="(item,index) in zhi" :key="index" @click="actindexs=index">
          <span>{{item.name}}</span>
          <img :src="item.pic" />
          <span><b v-show="actindexs===index">√</b></span>
        </div>
      </div>
      <div class="div">
        <h4>商品列表</h4>
        <div v-for="item in sum" :key="item.id">
          <div class="img">
            <img :src="item.pic" alt />
          </div>
          <div class="txt">
            <p>{{item.name}}</p>
            <p>
              <span>x{{item.count}}</span>
              <span>{{sum.reduce((total,item)=>{if(item.count)return total+item.count*item.money},0)}}</span>
            </p>
          </div>
        </div>
      </div>
      <div class="food">
        <p>
          总价：{{sum.reduce((total,item)=>{
          if(item.count){
          return total+item.count*item.money
          }
          },0)}}元
        </p>
        <button class="but">去支付</button>
      </div>
    </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      citys: [
        {
          city: "河南省固始县-香榭丽舍"
        },
        {
          city: "河南省固始县-秀水人家"
        },
        {
          city: "河南省固始县-云中酒屋"
        }
      ],
      actindex: 1,
      actindexs: 1,
      zhi: [
        {
          name: "微信",
          pic: "/img/w.png"
        },
        {
          name: "支付宝",
          pic: "/img/z.png"
        },
        {
          name: "银联",
          pic: "/img/y.png"
        }
      ]
    };
  },
  computed: {
    ...mapGetters(["sum"])
  }
};
</script>

<style lang='scss' scoped>
.zhifu {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  .city{
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: white;
    margin-top: 10px;
    h4{
      height: 40px;
      line-height: 40px;
      margin-left: 10px;
      border-bottom: 1px solid #f5f5f5;
    }
    b{
      color:greenyellow;
    }
    div{
      display: flex;
      justify-content: space-between;
      height: 40px;
      line-height: 40px;
      margin-left: 10px;
      border-bottom: 1px solid #f5f5f5;
    }
  }
  .zifu{
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: white;
    margin-top: 10px;
    h4{
      height: 40px;
      line-height: 40px;
      margin-left: 10px;
      border-bottom: 1px solid #f5f5f5;
    }
    img{
      width: 50px;
      height: 35px;
      margin-left: -50px;
    }
    b{
      color:greenyellow;
    }
    div{
      display: flex;
      justify-content: space-between;
      height: 40px;
      line-height: 40px;
      margin-left: 10px;
      border-bottom: 1px solid #f5f5f5;
    }
  }
  .div{
    flex:1;
    overflow: auto;
    h4{
      height: 40px;
      line-height: 40px;
      margin-left: 10px;
      border-bottom: 1px solid #f5f5f5;
    }
    div{
      margin-top: 10px;
      height: 100px;
      display: flex;
      align-items: center;
      .img{
        flex: 1;
        margin-left: 10px;
        margin-right: 10px;
      }
      .txt{
        flex: 3;
        display: flex;
        flex-direction: column;
        margin-top: 10px;
        p{
          span{
            margin-right: 20px;
          }
        }
      }
    }
  }
  .food {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0px;
    height: 50px;
    line-height: 50px;
    display: flex;
    justify-content: space-around;
    background: rgb(59, 58, 58);
    color: white;
    .but {
      width: 100px;
      background: rgb(47, 255, 82);
      border: none;
      outline: none;
      color: white;
    }
  }
}
</style>